﻿/**************************
*项目启动入口
*qykings
*201-09-01
*又是开学季啊，，，，，
*用于win下的测试用
*
**/

/***
*先不做跨平台
*有空在搞
**/
#include "SGameSocket.h"



#include "MySqlCenter.h"

#include "./file/fileOperate.h"

#include <fstream>
#include <cassert>
#include "./common/json/cJSON.h"

#include "mgr\DataMgr.h"
#include "ServerConfig.h"

#pragma comment(lib,"ws2_32.lib")

#pragma comment(lib, "pthreadVC2.lib")  //必须加上这句

		 

int main()
{
 
	//database configuartion
	MySqlCenter::GetInstance()->loadCof("./conf/DBConf");
	MySqlCenter::GetInstance()->connect();

	ServerConfig serverconfig;
	serverconfig.loadJson("./conf/serverConf");

 				    

	char buf[256]="";

	struct hostent *ph = 0;

	WSADATA w;

	WSAStartup(0x0101, &w);//这一行必须在使用任何SOCKET函数前写！

	gethostname(buf, 256);

	std::string hostNmae = buf;//此处获得本机名称

	ph = gethostbyname(buf);

	const char *IP =inet_ntoa(*((struct in_addr *)ph->h_addr_list[0]));//此处获得本机IP

	std::cout<<"ip:"<<IP<<std::endl;
	printf("port:%d\n",DataMgr::GetInstance()->port);
	SGameSocket::GetInstance()->creat( IP,DataMgr::GetInstance()->port );

	return 0;
}